package cn.xeblog.server.action.pina;

import cn.xeblog.server.config.ServerConfig;
import lombok.Data;

/**
 * @author eleven
 * @date 2024/11/27 14:37
 * @apiNote
 */
@Data
public class Limiter {
    private Integer msgCount;

    private Integer countLimit;

    private Integer limitTime;

    private Integer limitLevel;

    private Boolean limitFlag;

    public static Limiter defaultLimiter(ServerConfig config) {
        Limiter limiter = new Limiter();
        limiter.setLimitFlag(false);
        limiter.setCountLimit(config.getMaxLimit());
        limiter.setLimitTime(config.getLimitTime());
        limiter.setLimitLevel(config.getLimitTime());
        limiter.setMsgCount(0);
        return limiter;
    }
}
